<?php
namespace Plugin;

require_once dirname(__FILE__) . '/' . 'UniPush/send.php';
class UniPush
{

    public static function Send($title, $content, $payload, $cid = null)
    {
        // 生成指定格式的intent支持厂商推送通道
        $package  = PACKAGENAME; //包名
        $intent   = "intent:#Intent;action=android.intent.action.oppopush;launchFlags=0x14000000;component={$package}/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title={$title};S.content={$content};S.payload={$payload};end";
        $template = createPushMessage($payload, $intent, $title, $content);
        if (empty($cid)) {
            $is = pushMessageToApp($template);
        } elseif (is_array($cid)) {
            $is = pushMessageToList($template, $cid);
        } else {
            $is = pushMessageToSingle($template, $cid);
        }
        if (isset($is['result'])) {
            $is['state'] = $is['result'];
        }
        return $is;
    }
}
